package com.service.EasyExcel.Controller;

import com.service.EasyExcel.Service.FilteringRulesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author lqj
 * @version 1.0
 * @description:
 * @date 2022/5/15 14:09
 */
@RestController
@RequestMapping("/importExcel")
public class FilteringRulesController {


    @Autowired
    private FilteringRulesService filteringRulesService;
    /**
     * 读取excel文件
     * @param file
     * @return
     */
    @PostMapping("/importUser")
    public ResponseEntity<?> importUser(@RequestParam("file") MultipartFile file) {

        try {
            filteringRulesService.importUserExcel(file);
        } catch (Exception e) {
            return new ResponseEntity<>("导入失败失败", HttpStatus.INTERNAL_SERVER_ERROR);
        }
        return new ResponseEntity<>("导入成功", HttpStatus.OK);
    }

}
